package com.ineatconseil.yougo.client.ui.main.application;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * @author Benjamin Barbier - Ineat Conseil
 */
public class ApplicationViewImpl extends Composite implements IApplicationView {

	@UiField VerticalPanel mainVerticalPanel;
	
	@UiTemplate("ApplicationUiBinder.ui.xml")
	interface ApplicationUiBinder extends UiBinder<HTMLPanel, ApplicationViewImpl> {}

	private static ApplicationUiBinder uiBinder = GWT.create(ApplicationUiBinder.class);
	
	public ApplicationViewImpl() {
		System.out.println("ApplicationViewImpl - constructor");
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void addWidgetInMainVerticalPanel(IsWidget w, Activity a) {
		System.out.println("ApplicationViewImpl.addWidgetInMainVerticalPanel()");
		
		AcceptsOneWidget displayRegion = new SimplePanel();
		displayRegion.setWidget(w);
		
		//TODO: Passer le Bus par ici si besoin plus tard...
		a.start(displayRegion, null);
		
		mainVerticalPanel.add(w);
	}

}
